package com.restaurant.application.bookingset.support;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;
import com.nebutown.generation.basictype.UID;

import java.util.List;
import java.util.stream.Collectors;

public class BookingSetData implements PickableBean {

    public static final String FN_ID = "id";
    public static final String FN_SHOPUID = "shopUid";
    public static final String FN_SHOPID = "shopId";
    public static final String FN_SHOPNAME = "shopName";
    public static final String FN_STARTDATE = "startDate";
    public static final String FN_ENDDATE = "endDate";
    public static final String FN_TIMES = "times";
    public static final String FN_SERVICE = "service";
    public static final String FN_CREATETIME = "createTime";
    public static final String FN_MODIFYTIME = "modifyTime";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_ID,
            FN_SHOPUID,
            FN_SHOPID,
            FN_SHOPNAME,
            FN_STARTDATE,
            FN_ENDDATE,
            FN_TIMES,
            FN_SERVICE,
            FN_CREATETIME,
            FN_MODIFYTIME);
    
    private String id;
    private UID shopUid;
    private String shopId;
    private String shopName;
    private String startDate;
    private String endDate;
    private List<TimesData> times;
    private List<String> service;
    private Long createTime;
    private Long modifyTime;

    public BookingSetData(String id, UID shopUid, String shopId, String shopName, String startDate, String endDate, List<TimesData> times, List<String> service, Long createTime, Long modifyTime) {
        setId(id);
        setShopUid(shopUid);
        setShopId(shopId);
        setShopName(shopName);
        setStartDate(startDate);
        setEndDate(endDate);
        setTimes(times);
        setService(service);
        setCreateTime(createTime);
        setModifyTime(modifyTime);
    }

    public BookingSetData() {
    }

    public BookingSetData duplicate() {
        BookingSetData result = new BookingSetData();
        result.id = this.id;
        result.shopUid = this.shopUid;
        result.shopId = this.shopId;
        result.shopName = this.shopName;
        result.startDate = this.startDate;
        result.endDate = this.endDate;
        result.times = this.times == null ? null : this.times.stream().map(e1 -> e1 == null ? null : e1.duplicate()).collect(Collectors.toList());
        result.service = this.service == null ? null : this.service.stream().map(e2 -> e2).collect(Collectors.toList());
        result.createTime = this.createTime;
        result.modifyTime = this.modifyTime;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getId() {
        return id;
    }

    public void setId(String value) {
        this.id = value;
    }

    public BookingSetData withId(String value) {
        setId(value);
        return this;
    }

    public BookingSetData withId(String value, String defaultValue) {
        setId(value == null ? defaultValue : value);
        return this;
    }

    public UID getShopUid() {
        return shopUid;
    }

    public void setShopUid(UID value) {
        this.shopUid = value;
    }

    public BookingSetData withShopUid(UID value) {
        setShopUid(value);
        return this;
    }

    public BookingSetData withShopUid(UID value, UID defaultValue) {
        setShopUid(value == null ? defaultValue : value);
        return this;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String value) {
        this.shopId = value;
    }

    public BookingSetData withShopId(String value) {
        setShopId(value);
        return this;
    }

    public BookingSetData withShopId(String value, String defaultValue) {
        setShopId(value == null ? defaultValue : value);
        return this;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String value) {
        this.shopName = value;
    }

    public BookingSetData withShopName(String value) {
        setShopName(value);
        return this;
    }

    public BookingSetData withShopName(String value, String defaultValue) {
        setShopName(value == null ? defaultValue : value);
        return this;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String value) {
        this.startDate = value;
    }

    public BookingSetData withStartDate(String value) {
        setStartDate(value);
        return this;
    }

    public BookingSetData withStartDate(String value, String defaultValue) {
        setStartDate(value == null ? defaultValue : value);
        return this;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String value) {
        this.endDate = value;
    }

    public BookingSetData withEndDate(String value) {
        setEndDate(value);
        return this;
    }

    public BookingSetData withEndDate(String value, String defaultValue) {
        setEndDate(value == null ? defaultValue : value);
        return this;
    }

    public List<TimesData> getTimes() {
        if (times == null) {
            times = Lists.newArrayList();
        }
        return times;
    }

    public void setTimes(List<TimesData> value) {
        this.times = value;
    }

    public BookingSetData withTimes(List<TimesData> value) {
        setTimes(value);
        return this;
    }

    public BookingSetData withTimes(List<TimesData> value, List<TimesData> defaultValue) {
        setTimes(value == null ? defaultValue : value);
        return this;
    }

    public BookingSetData addTimes(TimesData value) {
        if (times == null) {
            times = Lists.newArrayList();
        }
        this.times.add(value);
        return this;
    }

    public List<String> getService() {
        if (service == null) {
            service = Lists.newArrayList();
        }
        return service;
    }

    public void setService(List<String> value) {
        this.service = value;
    }

    public BookingSetData withService(List<String> value) {
        setService(value);
        return this;
    }

    public BookingSetData withService(List<String> value, List<String> defaultValue) {
        setService(value == null ? defaultValue : value);
        return this;
    }

    public BookingSetData addService(String value) {
        if (service == null) {
            service = Lists.newArrayList();
        }
        this.service.add(value);
        return this;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long value) {
        this.createTime = value;
    }

    public BookingSetData withCreateTime(Long value) {
        setCreateTime(value);
        return this;
    }

    public BookingSetData withCreateTime(Long value, Long defaultValue) {
        setCreateTime(value == null ? defaultValue : value);
        return this;
    }

    public Long getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(Long value) {
        this.modifyTime = value;
    }

    public BookingSetData withModifyTime(Long value) {
        setModifyTime(value);
        return this;
    }

    public BookingSetData withModifyTime(Long value, Long defaultValue) {
        setModifyTime(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "id":
                return getId();
            case "shopUid":
                return getShopUid();
            case "shopId":
                return getShopId();
            case "shopName":
                return getShopName();
            case "startDate":
                return getStartDate();
            case "endDate":
                return getEndDate();
            case "times":
                return getTimes();
            case "service":
                return getService();
            case "createTime":
                return getCreateTime();
            case "modifyTime":
                return getModifyTime();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof BookingSetData)) return false;
        return signature().equals(((BookingSetData) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean BookingSetData has no signature defined, no hash code or equals possible.");
    }
}
